<?php
include "../action/degreesAction.php";
if(isset($_GET["action"]))
    $action = $_GET["action"];
else
    $action = "show";
$show = "";
if($action == "show")
{    
    $show = '<div class="top-bar">
                <h1>Danh Sach Bang Cap</h1>
    				<a href="mod.php?page=degrees&action=add" class="button">ADD NEW </a>
    			</div><table class="listing" cellpadding="0" cellspacing="0">
                                <tr>
    						<th class="first" width="177">Bang Cap</th>
                            <th>Mo ta</th>
                            <th>Xoa</th>
                            <th class="last">Sua</th>
                            </tr>';

    for ($i = 0; $i < $n; $i++) {
        $show .= "<tr><td class='first style2'>".$arrDegree[$i]["title"]."</td>";
        $show .= "<td class='first style2'>".$arrDegree[$i]["descript"]."</td>";
        $show .= "<td><a href='../action/degreesAction.php?action=deleted&id=".$arrDegree[$i]["id"]."' onclick='return confirm(".'"Ban muon xoa du lieu nay?"'.")?true:false;'><img src='../img/hr.gif' width='16' height='16' alt='' /></a></td>";
        $show .= "<td><a href='../admin/mod.php?page=degrees&action=edit&id=".$arrDegree[$i]["id"]."'><img src='../img/edit-icon.gif' width='16' height='16' alt='' /></a></td></tr>";
    }
    $show .= "</table>";
}

else if($action == "add")
{
    $show .= '<div class="top-bar">
                <h1>Bang Cap Moi</h1>
                    <form id="addForm" name="addForm" action="../action/degreesAction.php?action=added" method="POST">';
        $show .= '<table class="listing" cellpadding="0" cellspacing="0">
                <tr>
                    <td class="first style2" align=right width=30%>
                        Ten Bang Cap:
                    </td>
                    <td width=50%>
                        <input class="required" type="text" name="title" id="title" size=30/><br/>
                    </td>
                </tr>
                <tr>
                    <td class="first style2" align=right width=30%>
                        Mo Ta:
                    </td>
                    <td width=50%>
                        
                        <textarea name="descript" id="descript" style="width: 300px;"></textarea>
                    </td>
                </tr>
                <tr>
                    <td colspan = 2 align=center>
                        <input type="submit" value="Them"/>
                    </td>
                </tr>
                </table>
            </form>
 			               </div>
                ';
}
else if($action == "edit")
{
    $show .= '<div class="top-bar">
                <h1>Cap Nhat Bang Cap</h1>
                    <form id="addForm" name="addForm" action="../action/degreesAction.php?action=edited&id='.$degree['id'].'" method="POST">';
        $show .= '<table class="listing" cellpadding="0" cellspacing="0">
                <tr>
                    <td class="first style2" align=right width=30%>
                        Bang Cap:
                    </td>
                    <td width=50%>
                        <input class="required" type="text" name="title" id="title" size=30 value="'.$degree['title'].'"/><br/>
                    </td>
                </tr>
                <tr>
                    <td class="first style2" align=right width=30%>
                        Mo Ta:
                    </td>
                    <td width=50%>
                
                    
                        <textarea name="descript" id="descript" style="width: 300px;">'.$degree['descript'].'</textarea>
                    </td>
                </tr>
                <tr>
                    <td colspan = 2 align=center>
                        <input type="submit" value="Chap nhan"/>
                    </td>
                </tr>
                </table>
            </form>
 			               </div>
                ';
}
?>
